//
//  RPSettingView.m
//  RPCFCADemo_Example
//
//  Created by 宋鸿康 on 2022/10/19.
//  Copyright © 2022 john. All rights reserved.
//

#import "RPSettingView.h"

@interface RPSettingView()
@property(nonatomic, strong) UIImageView *icoImg;
@property(nonatomic, strong) UILabel *accountLabel;
@property(nonatomic, strong) UITextField *accountField;
@property(nonatomic, strong) UIView *lineView;
@end

@implementation RPSettingView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)initUI
{
    [self addSubview:self.icoImg];
    [self.icoImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(16);
        make.left.mas_equalTo(15);
        make.size.mas_equalTo(CGSizeMake(16, 16));
    }];
    
    [self addSubview:self.accountLabel];
    [self.accountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.icoImg.mas_right).offset(8);
        make.top.mas_equalTo(15);
    }];
    
    [self addSubview:self.accountField];
    [self.accountField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.inset(15);
        make.bottom.mas_equalTo(-8);
    }];
    
    [self addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.left.right.inset(15);
        make.height.mas_equalTo(0.5);
    }];
}

- (UIImageView *)icoImg
{
    if (!_icoImg) {
        _icoImg = [[UIImageView alloc] init];
        _icoImg.image = [UIImage imageNamed:@"jigouguanli"];
    }
    return _icoImg;
}

- (UILabel *)accountLabel
{
    if (!_accountLabel) {
        _accountLabel = [[UILabel alloc] init];
        _accountLabel.text = @"运营机构：";
        _accountLabel.font = [UIFont boldSystemFontOfSize:16];
        _accountLabel.textColor = [UIColor colorWithHexString:@"#2B2B2B"];
        _accountLabel.textAlignment = NSTextAlignmentCenter;
        [_accountLabel sizeToFit];
    }
    return _accountLabel;
}

- (UITextField *)accountField
{
    if (!_accountField) {
        _accountField = [[UITextField alloc] init];
        _accountField.textColor = [UIColor colorWithHexString:@"##C8C8C8"];
        _accountField.font = [CFTool font:15];
        _accountField.tintColor = [UIColor colorWithHexString:@"#C8C8C8"];
        _accountField.placeholder = @"请输入";
    }
    return _accountField;
}
- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor colorWithHexString:@"#D8D8D8"];
    }
    return _lineView;
}

- (void)updateByRow:(NSInteger)row
{
    NSString *str;
    if (row == 0) {
        str = @"运营机构：";
    }else if (row == 1){
        str = @"企业代码：";
    }else if (row == 2){
        str = @"登入账号：";
    }else if (row == 3){
        str = @"服务器地址：";
    }else if (row == 4){
        str = @"服务器端口：";
    }
    _accountLabel.text = str;
    _icoImg.image = [UIImage imageNamed:[NSString stringWithFormat:@"%zd",row + 1]];
}

- (NSString *)getResult
{
    return _accountField.text;
}

- (void)setText:(NSString *)text
{
    self.accountField.text = text;
}
@end
